AddDemo = {
		savedemo:function (){

			
			var model = document.getElementById("model").value;
			var seqNo = document.getElementById("seqNo").value;
			var license = document.getElementById("license").value;
			var demoAddress = document.getElementById("demoAddress").value;
			var nodes = document.getElementById("nodes").value;
			var hardwareSource = document.getElementById("hardwareSource").value;
			var productConfig = document.getElementById("productConfig").value;
			var note = document.getElementById("note").value;
			
			var module = document.getElementById("addModule").value;
			
			var pid = "";
			pid = document.getElementById("pid").value;
			
			var defaultModule = "";
			var customModule = "";
			
			if("定制模块"==module){
				customModule = document.getElementById("customModule").value;
			}else{
				defaultModule = document.getElementById("defaultModule").value;
			}
			
			if(model==0||model==''){
				   PigossMsg.alert("Demo机型号不能为空！");
				   return;
			}
			
			if(seqNo==0||seqNo==''){
				   PigossMsg.alert("序列号不能为空！");
				   return;
			}
			
			if(nodes==0||nodes==''){
				   PigossMsg.alert("节点数不能为空！");
				   return;
			}else{
				var isExit = false;
				var pattern2 = /^[0-9]*[1-9][0-9]*$/;
				if (pattern2.test(nodes)){
					isExit = true;
				}else if(isExit!=true){
					PigossMsg.alert("节点数不符合规则！");
					return;
				}
			}			
			
			AjaxUtil.request({
				url : 'add_demo.action',
				params : {pid:pid,model:model,seqNo:seqNo,license:license,demoAddress:demoAddress,nodes:nodes,defaultModule:defaultModule,customModule:customModule,hardwareSource:hardwareSource,productConfig:productConfig,note:note},
				success :function(responseText){
					//window.location.reload();
					RefreshDemo.refresh();
				},
				failure : function(){
					PigossMsg.alert("Added Failure!");
				}
			});
			imgCloseShow();			
		}
};

RefreshDemo= {
	   refresh:function(){
	       document.getElementById("queryDemoByCondition").submit();
	   }
};

EditDemo = {
		editConfig : function(){
			
			var projectNameId = document.getElementById("editProjectNameId").value;
			
			var id = document.getElementById("id").value;
			var model = document.getElementById("model").value;
			var seqNo = document.getElementById("seqNo").value;
			var license = document.getElementById("license").value;
			var demoAddress = document.getElementById("demoAddress").value;
			var nodes = document.getElementById("nodes").value;
			//var module = document.getElementById("module").value;
			var hardwareSource = document.getElementById("hardwareSource").value;
			var productConfig = document.getElementById("productConfig").value;
			var note = document.getElementById("note").value;
			
			var module = document.getElementById("editModule").value;
			var defaultModule = "";
			var customModule = "";
			
			if("定制模块"==module){
				customModule = document.getElementById("showEditModule").value;
			}else{
				defaultModule = document.getElementById("eidtDefaultModule").value;
			}
			
			if(model==0||model==''){
				   PigossMsg.alert("Demo型号不能为空！");
				   return;
			}
			if(seqNo==0||seqNo==''){
				   PigossMsg.alert("序列号不能为空！");
				   return;
			}
			if(nodes==0||nodes==''){
				   PigossMsg.alert("节点数不能为空！");
				   return;
			}
			AjaxUtil.request({
				url : 'update_out_demo.action',
				params : {pid:projectNameId,id:id,model:model,seqNo:seqNo,license:license,demoAddress:demoAddress,nodes:nodes,defaultModule:defaultModule,customModule:customModule,module:module,hardwareSource:hardwareSource,productConfig:productConfig,note:note},
				success :function(responseText){
					//window.location.reload();
					RefreshDemo.refresh();
				},
				failure : function(){
					PigossMsg.alert("Edit Failure!");
				}
			});	
			imgCloseShow();				    
		},
		
		del : function(did){
			AjaxUtil.request({
				url : 'delete_demo.action',
				params : {id:did},
				success : function(responseText){
					RefreshDemo.refresh();
				},
				failure : function(){
					PigossMsg.alert("Delete Failure!");
				}
			});
		},
		
		editLessDemo:function(){
			var id = document.getElementById("editId").value;
			var license = document.getElementById("editLicense").value;
			var nodes = document.getElementById("editNodes").value;
			var productConfig = document.getElementById("editProductConfig").value;
			var note = document.getElementById("editNote").value;
			
			var module = document.getElementById("editModule").value;
			var defaultModule = "";
			var customModule = "";
			
			if("定制模块"==module){
				customModule = document.getElementById("showEditModule").value;
			}else{
				defaultModule = document.getElementById("eidtDefaultModule").value;
			}
			
			if(showEditModule==0||showEditModule==''){
				   PigossMsg.alert("输入模块不能为空！");
				   return;
			}
			if(productConfig==0||productConfig==''){
				   PigossMsg.alert("硬件配置不能为空！");
				   return;
			}
			if(nodes==0||nodes==''){
				   PigossMsg.alert("节点数不能为空！");
				   return;
			}
			
			AjaxUtil.request({
				url : 'update_LessDemo.action',
				params : {id:id,license:license,nodes:nodes,productConfig:productConfig,note:note,defaultModule:defaultModule,customModule:customModule},
				success :function(responseText){
					//window.location.reload();
					RefreshDemo.refresh();
				},
				failure : function(){
					PigossMsg.alert("Edit Failure!");
				}
			});	
			imgCloseShow();		
			
		},
		editInDemo:function(){
			
			var id = document.getElementById("id").value;
			var model = document.getElementById("model").value;
			var seqNo = document.getElementById("seqNo").value;
			var license = document.getElementById("license").value;
			var demoAddress = document.getElementById("demoAddress").value;
			var nodes = document.getElementById("nodes").value;
			var hardwareSource = document.getElementById("hardwareSource").value;
			var productConfig = document.getElementById("productConfig").value;
			var note = document.getElementById("note").value;
			
			var module = document.getElementById("editModule").value;
			var defaultModule = "";
			var customModule = "";
			
			if("定制模块"==module){
				customModule = document.getElementById("showEditModule").value;
			}else{
				defaultModule = document.getElementById("eidtDefaultModule").value;
			}
			
			if(model==0||model==''){
				   PigossMsg.alert("Demo型号不能为空！");
				   return;
			}
			if(seqNo==0||seqNo==''){
				   PigossMsg.alert("序列号不能为空！");
				   return;
			}
			if(nodes==0||nodes==''){
				   PigossMsg.alert("节点数不能为空！");
				   return;
			}
			if(note==0||note==''){
				   PigossMsg.alert("备注不能为空！");
				   return;
			}
			var copyContactDate = document.getElementById("copyContactDate");
			var ableEquipment = document.getElementById("ableEquipment");
			
			if(!(copyContactDate.checked)){
				PigossMsg.alert("请选中是否备份客户数据，并确保已备份客户数据！");
				return;
			}
			AjaxUtil.request({
				url : 'update_in_demo.action',
				params : {id:id,model:model,seqNo:seqNo,license:license,demoAddress:demoAddress,nodes:nodes,defaultModule:defaultModule,customModule:customModule,module:module,hardwareSource:hardwareSource,productConfig:productConfig,note:note},
				success :function(responseText){
					//window.location.reload();
					RefreshDemo.refresh();
				},
				failure : function(){
					PigossMsg.alert("Edit Failure!");
				}
			});	
			imgCloseShow();
		}
};

